<?php
include("imageThumb.class.php");
include("upload.class.php");
include("function.php");
$upload=new uploadFile();

$upload->files= $_FILES['up_image'];
$upload->uploaded="cache/avatar".$_SESSION['login_mail'];
$upload->allow_types="jpeg|jpg|JPG|JPEG";
$upload->save_path="cache/";
$upload->file_name="avatar".$_SESSION['login_mail'];
$upload->upload_file($_FILES['up_image']);

if($upload->errmsg != ""){
	$err=$upload->errmsg;
	echo "<script language=\"javascript\">alert('$err');</script>";
	echo "<script language=\"javascript\">history.go(-1);</script>";
	
}else{
	$pictureup=$upload->uploaded;
	$picture=$upload->uploaded;
	$resizeimage = new myThumbClass($pictureup,1,400,$picture,-1,0);  //生成高度400
	$type = strtolower(substr(strrchr($picture,"."),1));	//获取图片类型
	echo "<script type=\"text/javascript\">location.href='edit_user_info.php?picture=$picture&avatar=1&type=$type';</script>";
}
	?>